#include <iostream>
#include <string>
using namespace std;

string countAndSay(int n);

int main(int argc, char** argv){


    cout<<countAndSay(4)<<endl;

    return 0;
}

string GetNext(string &str){
    int length = str.length();
    int cur = 0;
    string res;
    while(cur<length){
        char curChar = str[cur];
        int endIndex = cur+1;
        while(endIndex<length){
            if(str[endIndex] != curChar){
                break;
            }
            ++endIndex;
        }
        // ok [cur, endIndex) is same
        char temp[256];
        sprintf(temp, "%d%c", (endIndex-cur), curChar);
        res += string(temp); 
        cur = endIndex;
    }
    return res;
}

string countAndSay(int n) {
    // Start typing your C/C++ solution below
    // DO NOT write int main() function
    string cur("1");
    while(--n){
       cur = GetNext(cur);
    }

    return cur;
}